unit TeknikSozlesme;
                                    
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridLevel, cxClasses,         
  cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxGrid, XPMan, StdActns, ActnList, cxButtonEdit,
  cxDBLookupComboBox, cxCheckBox, cxDropDownEdit, cxImageComboBox;

type
  TfmTeknikSozlesme = class(TfmFormClass)
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    aqEntry: TADOQuery;
    dsEntry: TDataSource;
    cxGrid1DBTableView1BasTarih: TcxGridDBColumn;
    cxGrid1DBTableView1BitTarih: TcxGridDBColumn;
    cxGrid1DBTableView1Bolum: TcxGridDBColumn;
    cxGrid1DBTableView1Carikodu: TcxGridDBColumn;
    cxGrid1DBTableView1UstGrup: TcxGridDBColumn;
    cxGrid1DBTableView1Grup: TcxGridDBColumn;
    cxGrid1DBTableView1Stokkodu: TcxGridDBColumn;
    cxGrid1DBTableView1GecenGun: TcxGridDBColumn;
    cxGrid1DBTableView1YapilacakGun: TcxGridDBColumn;
    cxGrid1DBTableView1GiristeUyariver: TcxGridDBColumn;
    cxGrid1DBTableView1Aktif: TcxGridDBColumn;
    TipiQ: TADOQuery;
    dsTipi: TDataSource;
    cxGrid1DBTableView1Oncelik: TcxGridDBColumn;
    cxGrid1DBTableView1Temsilcisi: TcxGridDBColumn;
    aqTemsilci: TADOQuery;
    dsTemsilci: TDataSource;
    cxGrid1DBTableView1Mesaj: TcxGridDBColumn;
    cxGrid1DBTableView1Mail: TcxGridDBColumn;
    cxGrid1DBTableView1GelisAdet: TcxGridDBColumn;
    cxGrid1DBTableView1GarantiDurumu: TcxGridDBColumn;
    cxGrid1DBTableView1SatisGunFark: TcxGridDBColumn;
    cxGrid1DBTableView1Durumu: TcxGridDBColumn;
    cxGrid1DBTableView1Ozelkod: TcxGridDBColumn;
    cxGrid1DBTableView1UstBolum: TcxGridDBColumn;
    cxGrid1DBTableView1TamamlaGonder: TcxGridDBColumn;
    cxGrid1DBTableView1ilkyilGelisAdet: TcxGridDBColumn;
    cxGrid1DBTableView1ikiyilGelisAdet: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure cxGrid1DBTableView1StokkoduPropertiesValidate(
      Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
      var Error: Boolean);
    procedure cxGrid1DBTableView1CarikoduPropertiesValidate(
      Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
      var Error: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmTeknikSozlesme: TfmTeknikSozlesme;

implementation
uses data, UnitGenel, boxes;
{$R *.dfm}

procedure TfmTeknikSozlesme.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmTeknikSozlesme := nil;
end;

procedure TfmTeknikSozlesme.FormShow(Sender: TObject);
begin
  inherited;
  OpenQueryOnDataSet(aqTemsilci.SQL.Text, aqTemsilci);
  OpenQueryOnDataSet(TipiQ.SQL.Text, TipiQ);
  OpenQueryOnDataSet(aqEntry.SQL.Text, aqEntry);
end;

procedure TfmTeknikSozlesme.cxGrid1DBTableView1StokkoduPropertiesValidate(
  Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
  var Error: Boolean);
var
  Bilgi: string;
  StokKod: integer;
  Stokkodu: string[25];
  StokFisiTipi: char;
begin
  TcxButtonEdit(sender).Tag := 1;
  Bilgi := StokBul(Sender, 0, StokFisiTipi);

  if Bilgi = '' then
    exit;

  if Bilgi <> '0' then
  begin
    Stokkod := Strtoint(Copy(Bilgi, 1, Pos(',', Bilgi) - 1));
    Delete(Bilgi, 1, Pos(',', Bilgi));
    Stokkodu := Copy(Bilgi, 1, Pos(',', Bilgi) - 1);

    if not (aqEntry.State in [dsInsert, dsEdit]) then
      aqEntry.Edit;
    aqEntry.FieldByName('stokkod').AsInteger := Stokkod;
    aqEntry.FieldByName('stokkodu').AsString := Stokkodu;
  end
  else
  begin
    aqEntry.FieldByName('stokkod').Value := null;
    aqEntry.FieldByName('stokkodu').AsString := '';
  end;
end;

procedure TfmTeknikSozlesme.cxGrid1DBTableView1CarikoduPropertiesValidate(
  Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
  var Error: Boolean);
var
  Bilgi: string;
  CariKod: integer;
  Carikodu: string[25];
begin
  (Sender as TComponent).Tag := 10000;
  Bilgi := CariBul(Sender);

  if (Bilgi <> '0') and (Bilgi <> '') then
  begin
    Carikod := Strtoint(Copy(Bilgi, 1, Pos(',', Bilgi) - 1));
    Delete(Bilgi, 1, Pos(',', Bilgi));
    Carikodu := Copy(Bilgi, 1, Pos(',', Bilgi) - 1);

    aqEntry.FieldByName('Carikod').AsInteger := Carikod;
    aqEntry.FieldByName('Carikodu').AsString := Carikodu;
  end
  else
  begin
    aqEntry.FieldByName('Carikod').Value := Null;
    aqEntry.FieldByName('Carikodu').AsString := '';
  end;
end;


end.

